<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>备授课 - 析码无界</title>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
    <link rel="stylesheet" href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background-color: #f5f5f5;
        }
        .navbar {
            border-radius: 0;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border: none;
        }
        .navbar-brand {
            color: white !important;
            font-weight: bold;
        }
        .navbar-nav > li > a {
            color: rgba(255,255,255,0.9) !important;
        }
        .navbar-nav > li > a:hover {
            color: white !important;
            background-color: rgba(255,255,255,0.1) !important;
        }
        .main-content {
            margin-top: 20px;
        }
        .panel {
            border: none;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            border-radius: 8px;
        }
        .panel-heading {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 8px 8px 0 0;
        }
        .btn-primary {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border: none;
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand" th:href="@{/teacher}" style="display: flex; align-items: center;">
                    <div class="avatar-container" style="display: inline-block; margin-right: 10px; vertical-align: middle;">
                        <img th:src="${session.teacher?.avatar != null and !session.teacher.avatar.isEmpty() ? '/' + session.teacher.avatar : ''}" 
                             style="width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.8); object-fit: cover; cursor: pointer; transition: transform 0.2s;"
                             th:onclick="'location.href=\'' + @{/teacher/settings} + '\''"
                             onerror="if(this.src.indexOf('data:image') === -1) { this.onerror=null; this.src=''; }"
                             alt="头像">
                    </div>
                    <span><i class="fa fa-graduation-cap"></i> 析码无界 - 教师管理平台</span>
                </a>
            </div>
            <ul class="nav navbar-nav">
                <li><a th:href="@{/teacher/profile}">个人信息</a></li>
                <li><a th:href="@{/teacher/settings}"><i class="fa fa-cog"></i> 设置</a></li>
                <li class="active"><a th:href="@{/course/list}"><i class="fa fa-book"></i> 备授课</a></li>
                <li><a th:href="@{/assignment/list}">作业管理</a></li>
                <li><a th:href="@{/class/list}">班级管理</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="/"><i class="fa fa-sign-out"></i> 退出登录</a></li>
            </ul>
        </div>
    </nav>

    <div class="container main-content">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-book"></i> 备授课</h3>
            </div>
            <div class="panel-body">
                <div th:if="${message}" class="alert alert-success" th:text="${message}"></div>
                <div th:if="${error}" class="alert alert-danger" th:text="${error}"></div>
                
                <div style="margin-bottom: 20px;">
                    <a th:href="@{/course/create}" class="btn btn-primary">
                        <i class="fa fa-plus"></i> 创建新课程
                    </a>
                </div>
                
                <div th:if="${courses != null and !courses.isEmpty()}">
                    <div class="row">
                        <div th:each="course : ${courses}" class="col-md-4" style="margin-bottom: 20px;">
                            <div class="panel panel-default">
                                <div class="panel-body">
                                    <div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px;">
                                        <h4 style="margin: 0;" th:text="${course.courseName}"></h4>
                                        <a th:href="@{/course/delete(courseId=${course.id})}" 
                                           class="btn btn-danger btn-xs" 
                                           th:onclick="'return confirm(\'确定要删除课程【' + ${course.courseName} + '】吗？删除后将无法恢复，包括课程下的所有资源！\');'"
                                           title="删除课程">
                                            <i class="fa fa-trash"></i>
                                        </a>
                                    </div>
                                    <p th:if="${course.semester != null}" class="text-muted">
                                        <i class="fa fa-calendar"></i> <span th:text="${course.semester}"></span>
                                        <span th:if="${course.courseType != null}" th:text="' | ' + ${course.courseType}"></span>
                                    </p>
                                    <p th:if="${course.description != null}" class="text-muted" style="max-height: 60px; overflow: hidden;">
                                        <span th:text="${course.description}"></span>
                                    </p>
                                    <div style="margin-top: 15px;">
                                        <a th:href="@{/course/detail(courseId=${course.id})}" class="btn btn-primary btn-sm">
                                            <i class="fa fa-arrow-right"></i> 进入课程
                                        </a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div th:if="${courses == null or courses.isEmpty()}" class="alert alert-info">
                    <i class="fa fa-info-circle"></i> 您还没有创建任何课程，请点击"创建新课程"开始。
                </div>
            </div>
        </div>
    </div>
</body>
</html>

